Skip to content

Improve handling of mainThreadPrefix and remove redundant null check #34746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

zzoe2346
Copy link
Contributor

This Pull Request refactors the isCurrentThreadAllowedToHoldSingletonLock method to improve the consistency of mainThreadPrefix variable usage and remove a redundant null check.

Changes

Consistent Variable Usage

  • After assigning the value of this.mainThreadPrefix to the local variable mainThreadPrefix at the beginning of the method, the subsequent if check now consistently uses the local variable (if (mainThreadPrefix != null) instead of if (this.mainThreadPrefix != null)).

Removed Redundant Null Check

  • The mainThreadPrefix != null check within the else if (this.strictLocking == null) block has been removed.
  • This check was redundant because if (maainThreadPrefix != null) condition has already passed, guaranteeing the variable is not null at that point.

I hope my PR useful :)
Thank you.

@zzoe2346 zzoe2346 changed the title Refactor: Improve mainThreadPrefix usage consistency and remove redundant check in isCurrentThreadAllowedToHoldSingletonLock method Refactor: Improve variable usage consistency and remove redundant check in isCurrentThreadAllowedToHoldSingletonLock method Apr 12, 2025
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 12, 2025
@zzoe2346 zzoe2346 changed the title Refactor: Improve variable usage consistency and remove redundant check in isCurrentThreadAllowedToHoldSingletonLock method Refactor: Improve variable usage consistency and remove redundant null check Apr 12, 2025
@sbrannen sbrannen requested a review from jhoeller April 15, 2025 10:52
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Apr 15, 2025
@sbrannen sbrannen changed the title Refactor: Improve variable usage consistency and remove redundant null check Improve handling of mainThreadPrefix and remove redundant null check Apr 15, 2025
@jhoeller jhoeller added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 22, 2025
@jhoeller jhoeller self-assigned this Apr 22, 2025
@jhoeller jhoeller added this to the 6.2.7 milestone Apr 22, 2025
@jhoeller
Copy link
Contributor

Good catch! Thanks for spotting this.

@jhoeller jhoeller merged commit d3a5aef into spring-projects:main Apr 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants